var Myself163MailView = {//修改163邮箱的VIEW类实现
	createNew : function() {
		
		var myself163MailView = MyselfView.createNew();
		//创建自己下拉框的方法
		myself163MailView.createMailDropDownList = function() {
			//
			//can jquery node convert to normal html node?
			/*var formDropDownList = $("<div/>");
			//alert(formDropDownList);
			formDropDownList.id = "_enotes_input_list";
			formDropDownList.addClass("js-component-button");
			formDropDownList.addClass("qj");
			formDropDownList.attr("role","navigation");*/
			//this code can be successful!!!
			//div can regist a event and response click
			var formDropDownList = document.createElement('div');
			formDropDownList.className = 'js-component-button nui-ipt nui-ipt-hasIconBtn';
			formDropDownList.id = '_enotes_input_list';
			//add a label
			var formDropDownListLabel = document.createElement('label');
			formDropDownListLabel.id = '_enotes_input_label';
			formDropDownListLabel.className = 'nui-ipt-placeholder';
			formDropDownListLabel.textContent = '报表选择生成';
			//append child
			formDropDownList.appendChild(formDropDownListLabel);
			//add a input
			var formDropDownListInput = document.createElement('input');
			formDropDownListInput.className = 'nui-ipt-input';
			formDropDownListInput.type = 'text';
			formDropDownListInput.autoComplete = 'off';
			//append child
			formDropDownList.appendChild(formDropDownListInput);
			//add a span
			var formDropDownListSpan = document.createElement('span');
			formDropDownListSpan.className = 'nui-ipt-iconBtn';
			formDropDownListSpan.hideFocus='hidefocus';
			formDropDownListSpan.tabIndex = '0';
			//append child
			formDropDownList.appendChild(formDropDownListSpan);
			//add a arrow to span
			var formDropDownListSpanArrow = document.createElement('b');
			formDropDownListSpanArrow.className = 'js-component-icon nui-ico nui-ico-dArr';
			formDropDownListSpanArrow.id = '_mail_icon_15_107';
			formDropDownListSpan.appendChild(formDropDownListSpanArrow);

			//register event 
			$(formDropDownList).click(function() {
				$('#_enotes_input_label').text(function(n,current) {
					return '';
				});
			});
			return formDropDownList;
		}
		//创建自己的邮箱按钮的方法
		myself163MailView.createMailWriteToolButton = function(btn_name,btn_id,m_inx,s_inx) {
			var encryButtonDivSubSpan = document.createElement('span');
			encryButtonDivSubSpan.className = 'nui-btn-text'
			encryButtonDivSubSpan.textContent = btn_name;
			var encryButtonDivSubDiv = document.createElement('div');
			encryButtonDivSubDiv.id = '_mail_button_' + m_inx.toString() + '_' + s_inx.toString();
			encryButtonDivSubDiv.className='js-component-button nui-btn';
			encryButtonDivSubDiv.tabIndex='2'
			encryButtonDivSubDiv.appendChild(encryButtonDivSubSpan);
			var encryButtonDiv = document.createElement('div');
			encryButtonDiv.className = 'nui-toolbar-item';
			encryButtonDiv.appendChild(encryButtonDivSubDiv);
			encryButtonDiv.id = btn_id;
			return encryButtonDiv;
		}
		//获取163写邮件的区域的上部工具箱
		//这里需要重新架构这个类，方法之间不能耦合太深
		myself163MailView.insertComponentToMailWriteTopToolBarZone = function() {
			var m_inx,s_inx;
			var buttonZoneDiv,buttonPosNode;
			$('#divComposeToolbar').each(function(idx) {
				$(this).children().each(function(idx_child) {
					if(this.id.match(/_mail_toolbar_\d+_\d+/)) {
						buttonZoneDiv = this;
						$(buttonZoneDiv).children().each(function(idx_c_child) {
							if(this.className === 'nui-toolbar-ext') {
								var buttonMainDiv = buttonZoneDiv.childNodes[idx_c_child - 1];
								var idArr = buttonMainDiv.childNodes[0].id.split('_');
								m_inx = parseInt(idArr[idArr.length - 2]);
								s_inx = parseInt(idArr[idArr.length - 1]);
								buttonPosNode = this;
							}
						});
					}
				});
			});
			var buttonNode = this.createMailWriteToolButton('解密','topBtn_decry',(m_inx + 1),(s_inx + 1));
			this.pushMyNodes(buttonZoneDiv,buttonNode,buttonPosNode);
			buttonNode = this.createMailWriteToolButton('加密','topBtn_encry',(m_inx + 2),(s_inx + 2));
			this.pushMyNodes(buttonZoneDiv,buttonNode,buttonPosNode);
			var dropDownListNode = this.createMailDropDownList();
			this.pushMyNodes(buttonZoneDiv,dropDownListNode,buttonPosNode);
		}
		//获取163邮箱底部工具箱
		myself163MailView.insertComponentToMailWriteBottomToolBarZone = function() {
			var m_inx,s_inx;
			var bottomToolBarDiv;
			$('footer').each(function(idx) {
				if(this.className != undefined && this.className === 'lN') {
					$(this).children().each(function(idx_child) {
						if(this.id.match(/_mail_toolbar_\d+_\d+/)) {
							var lastButtonSubDiv = this.childNodes[this.childNodes.length - 1];
							var idArr = lastButtonSubDiv.childNodes[0].id.split('_');
							m_inx = parseInt(idArr[idArr.length - 2]);
							s_inx = parseInt(idArr[idArr.length - 1]);
							bottomToolBarDiv = this;
						}
					});
				}
			});
			var buttonNode = this.createMailWriteToolButton('解密','bottomBtn_decry',(m_inx + 1),(s_inx + 1));
			this.pushMyNodes(bottomToolBarDiv,buttonNode,null);
			buttonNode = this.createMailWriteToolButton('加密','bottomBtn_encry',(m_inx + 2),(s_inx + 2));
			this.pushMyNodes(bottomToolBarDiv,buttonNode,null);
		}
		myself163MailView.initView = function() {
			//初始化
			this.insertComponentToMailWriteTopToolBarZone();
			this.insertComponentToMailWriteBottomToolBarZone();
		}
		return myself163MailView;
	}
}
